/********************************
 * ETK - Easy ToolKit
 * Copyright (C) 2007-2008 Ekinoks (scv.ekinoks@gmail.com)
 * All rights reserved.
 *
 *    This file is part of ETK.
 *
 *    Foobar is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    Foobar is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with Foobar; if not, write to the Free Software
 *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 ***********************************************************************************/

#include "ShutterButtonModel.h"
#include "ShutterButton.h"

namespace etk
{
    bool ShutterButtonModel::operator== (const ShutterButton& shutterButton) const
    {
        assert( (shutterButton.button_ != -1) && (shutterButton.eventType_ != -1) && "ToolKit::updateEvent uncalled" );

        if(button_ != 0)
            if((button_ & shutterButton.button_) != shutterButton.button_)
                return false;

        if(eventType_ != 0)
            if((eventType_ & shutterButton.eventType_) != shutterButton.eventType_)
                return false;

        return true;
    }

    bool ShutterButtonModel::operator!= (const ShutterButton& shutterButton) const
    {
        return !((*this)==shutterButton);
    }

    bool ShutterButtonModel::operator== (const ShutterButtonModel& shutterButtonModel) const
    {
        return (button_ == shutterButtonModel.button_) && (eventType_ == shutterButtonModel.eventType_);
    }

    bool ShutterButtonModel::operator!= (const ShutterButtonModel& shutterButtonModel) const
    {
        return !((*this)==shutterButtonModel);
    }

    const ShutterButtonModel ShutterButtonModel::BUTTON1(1<<0, 0);
    const ShutterButtonModel ShutterButtonModel::BUTTON2(1<<1, 0);
    const ShutterButtonModel ShutterButtonModel::BUTTON3(1<<2, 0);
    const ShutterButtonModel ShutterButtonModel::BUTTON4(1<<3, 0);
    const ShutterButtonModel ShutterButtonModel::BUTTON5(1<<4, 0);

    const ShutterButtonModel ShutterButtonModel::CLICK(0, 1<<0);
    const ShutterButtonModel ShutterButtonModel::DOUBLE_CLICK(0, 1<<1);
    const ShutterButtonModel ShutterButtonModel::TRIPLE_CLICK(0, 1<<2);
    const ShutterButtonModel ShutterButtonModel::RELEASE(0, 1<<3);

    const ShutterButtonModel ShutterButtonModel::ANY(0, 0);

}
